package app;

import cn.hsa.hsaf.idgenerator.IdGenerator;
import org.apache.commons.lang3.RandomStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

/**
 * Spring Boot 应用的入口文件
 * @author gu
 */
@SpringBootApplication
@ComponentScan(basePackages = {"app","cn.hsa.hsaf.idgenerator"})
public class WebAppStart {
    private static final Logger logger = LoggerFactory.getLogger(WebAppStart.class);
    public static void main(String[] args) {
        ConfigurableApplicationContext context =  SpringApplication.run(WebAppStart.class, args);
        System.out.println("App Started!");
        IdGenerator idGenerator = (IdGenerator)context.getBean("IdGenerator");
        String name = RandomStringUtils.randomAlphabetic(5);
        for (int i = 0; i < 10; i++) {
            logger.info("IdGenerator:{}",idGenerator.next(name));
        }
    }
}
